from datetime import datetime
from pydantic import Field
from schema.response.confBaseModel import ConfBaseModel


class BlogUserResponse(ConfBaseModel):
    id: int = Field(..., description="用户id")
    username: str = Field(..., description="用户名")

    class Config:
        from_attribute = True



class BlogCategoryResponse(ConfBaseModel):
    id: int = Field(..., description="博客类型id")
    title: str = Field(..., description="博客类型标题")
    create_time: datetime = Field(..., description="创建时间")
    update_time: datetime = Field(..., description="更新时间")

    class Config:
        from_attribute = True


class BlogResponse(ConfBaseModel):
    id: int = Field(..., description="博客id")
    title: str = Field(..., description="标题")
    content: str = Field(..., description="内容")
    category: BlogCategoryResponse = Field(..., description="博客类型")
    user: BlogUserResponse = Field(..., description="用户")
    create_time: datetime = Field(..., description="创建时间")
    update_time: datetime = Field(..., description="更新时间")

    class Config:
        from_attribute = True
